//GENERAL

var rad_val;

function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); 
}

function dozip() {
	document.getElementById('kzip').value = document.getElementById('xkzip').value;
	document.getElementById('zipform').submit();
}

function selectAll(theField) {
  var tempval=eval("document.getElementById('myemail')")
  tempval.focus()
  tempval.select()
}

//AJAX CALLS

function loadfiles(myd) {
	if (myd) {
		callAHAH('loadfiles.php?d='+myd, 'thefiles','<span class="ajaxmessage">Loading files - please wait</span>', 'Error');
	}
}
function mylist(space,add) {
	callAHAH('filelist.php?zone='+space+'&add='+add, 'mybasket',' Loading please wait ...', 'Error');
}
function clearbasket() {
	callAHAH('filelist.php?clear=yes', 'mybasket',' Clearing please wait ...', 'Error');
}
function remove(what) {
	callAHAH('filelist.php?remove='+what, 'mybasket',' Removing please wait ...', 'Error');
}
function sendlist() {
	//Marian ... removed the check on the email field, kept only the rad_val check
	//alert(rad_val);
	var total ="";
	if (rad_val=="loadit") {
		callAHAH('filelist.php?doit='+rad_val, 'mybasket',' Processing - please wait ...', 'Error');
	}
	
	if (rad_val=="saveit"){
		alert("Get Files?")
				
		var inputs = document.getElementById('TBOServerBrowse').getElementsByTagName('input');
		for(var i=0; i < inputs.length; i++){
			var input = inputs[i];
			if(input.checked)
			{
				//alert(input.getAttribute('path'));
				total +=input.getAttribute('path') + ":"
			}
			//alert(input.checked);			
		}
		//alert("Getting Files" + total);
		
		if(total=="")
			alert("You must check files first....");
		else 
			{				
				callAHAH('serverfiles.php?doit='+rad_val+'&files='+total, 'test',' Processing - please wait ...', 'Error');		
			}
	}
}

//Marian .. adding this to handle files listing of remote server ... 
function go(gowhere){
	if(gowhere){
		callAHAH('serverfiles.php?gowhere='+gowhere, 'test',' Retrieveing file list..please wait....', 'Error');
	}
}

//Function to display error messages as appropriate
function showErrorMessage(message){
	alert(message);
}

//BG CELL CHANGER
var oncell = "0"

function overm(celno) { 
	var chgcell
	if (document.layers) { // browser is NN
		chgcell = "window.document."+ celno + ".bgColor='#c0d2ec'";
	} else { //assume IE
		chgcell = "document.getElementById('"+ celno + "').bgColor='#c0d2ec'";
	}
 	eval(chgcell);
}

function outm(celno) { 
	var chgcell
	if (document.layers) { // browser is NN
		chgcell = "window.document."+ celno + ".bgColor='white'";
	} else { //assume IE
		chgcell = "document.getElementById('"+ celno + "').bgColor='white'";
	}
	eval(chgcell);
}

//SELECT AND DISSELECT CHECK BOXES
function checkAll(mynum) {
	var mynum;
	for (var j = 1; j <= mynum; j++) {
		box = eval("document.listform.chkbox_" + j);
		if (box.checked == false) box.checked = true;
	}
}
function uncheckAll(mynum) {
	var mynum;
	for (var j = 1; j <= mynum; j++) {
		box = eval("document.listform.chkbox_" + j);
		if (box.checked == true) box.checked = false;
   }
}
function switchAll(mynum) {
	var mynum;
	for (var j = 1; j <= mynum; j++) {
		box = eval("document.listform.chkbox_" + j);
		box.checked = !box.checked;
   }
}

//ACTION COMFIRMATION
function confirmaction(myURL,myMES){
	var res = confirm(myMES);
	if(res){
		location.href=myURL;
	}
}
